import requests
# from lxml import etree
from pyquery import PyQuery

# from bs4 import BeautifulSoup

count = 1
url = "https://www.169tp.com/rentiyishu/"
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36'}
reponse = requests.get(url, headers=headers).text
# print(reponse)
doc = PyQuery(reponse)
url_data = doc('.product01 li a').items()
for i in url_data:
    xulie = i.attr('href')
# print(xulie)

reponse1 = requests.get(xulie, headers=headers).text

# print(reponse1)
doc2 = PyQuery(reponse1)
tupian = doc2('.big_img p img').items()
for k in tupian:
    img = k.attr('src')
# title = k.attr('alt')
# print(img)


contont = requests.get(img, headers=headers)
with open('/Users/yongli/模特\美女{}.jpg'.format(count), 'wb') as f:
    f.write(contont.content)
print('已经下载了{}张'.format(count))
count += 1